<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>index</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../../../css/mui.min.css">
		<meta name="referrer" content="never" />
		<link rel="stylesheet" href="../work.css" />
		<link rel="stylesheet" href="../../static/css/common.css">
		<link rel="stylesheet" href="../../static/components/components.css" />
		<link rel="stylesheet" type="text/css" href="../../../../css/mui.picker.min.css" />
		 <link rel="stylesheet" type="text/css" href="../../../../css/mui.poppicker.css" />
		 <link rel="stylesheet" type="text/css" href="../../../../css/mui.picker.css" />
		<style>
			html,
			body {
				background-color: #efeff4;
			}
			.selsect-box{
				width: 40vw;
				height: 30px;
				border: 1px solid #999;
				line-height: 30px;
				box-sizing: border-box;
				padding-left: 5px;
			}
			.th{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 10px;
				width: 85vw;
				height: 30px;
				align-items: center;
				background-color: #fafafa;
				box-sizing: border-box;
				padding: 0 5px;
				border: 1px solid #999;
			}
			.tr{
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 85vw;
				height: 40px;
				align-items: center;
				border:1px solid #999;
				border-top: none;
				box-sizing: border-box;
				padding: 0 5px;
			}
			.left-title{
				width: 30vw;
			}
			.right-ipt{
				width: 40vw;
				height: 30px;
				border: 0px 1px 1px 1px solid #fafafa
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav mui-bar-nav-bg">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">集控机房巡检</h1>
		</header>
		<div class="mui-content" id="content">
			<div class="main_box">
				<div class="main_icon"></div>
				<div class="main_icon1"></div>
				<div class="box_title flex-row">
					<div class="icon"></div>
					<div style="font-size: 4vw;">基本信息</div>
				</div>
				<div class="flex-row mt-10">
					<div style="width: 25vw;padding-left: 10px;">巡视时间</div>
					<div>{{nowDate}}</div>
				</div>
				<div class="flex-row mt-10">
					<div style="width: 25vw;padding-left: 10px;">巡视人</div>
					<div>{{user.name}}</div>
				</div>
				<hr size="1" style="color: #999;border-style: dashed; widows: 250px;" />

				<div class="flex-between mt-10" >
					<div>本次测试记录</div>
					<div @tap="showAdd=true" class="submit_btn" style="margin: 0;padding: 0 2vw;height: 20px;">
						+
					</div>
				</div>
				<div style="margin-bottom: 20px;" v-for="(item,index) in list" :key="index">	
					<div class="th">
						<div class="">{{index + 1}}</div>
						<div class="color-red" @click="delItem(index)">删除</div>
					</div>
					<div class="tr">
						<div class="left-title">设备名称</div>
						<input v-model="item.deviceName" maxlength="60" class="right-ipt" placeholder="请输入" />
					</div>
					<div class="tr">
						<div class="left-title">设备型号</div>
						<input v-model="item.deviceCode"   maxlength="60" class="right-ipt" placeholder="请输入" />
					</div>
					<div class="tr">
						<div class="left-title">检查结果</div>
						<input v-if="item.resultType == 1" v-model="item.result" :onkeyup="item.result = item.result.replace(/\s+/g,'')"  maxlength="60" class="right-ipt" placeholder="请输入" />
						<div class="flex-row"  v-else>
							正常 <input :name="index" v-model="item.result" value="1" style="width: 18px;margin-right: 5px;" type="radio" id="">
							异常 <input :name="index" v-model="item.result" value="2" style="width: 18px;margin-right: 5px;" type="radio" id="">
						</div>
					</div>
				
					<div class="tr">
						<div class="left-title">备注</div>
						<input v-model="item.remark" maxlength="60" class="right-ipt" placeholder="请输入备注" />
					</div>
				</div>	
				<hr size="1" style="color: #999;border-style: dashed; widows: 250px;" />


				<div class="flex-between list-head">
					<div class="flex-row" style="font-weight: bold;">
						<div class="icon"></div>
						流程日志
					</div>
				</div>
				<processlog :processlogid='workId'></processlog>
			</div>
			<div class="popup-bg" v-if="showAdd">
				<div style="padding: 15px 15px 0px" class="add-box">
					<div class="flex-row">
						<div style="width: 70vw;font-size: 17px;">新增设备</div>
					</div>
					<div class="flex-row mt-10">
						<div>设备名称</div>
						<input v-model="formData.deviceName"  :keyup="formData.deviceName=formData.deviceName.replace(/\s+/g,'')" maxlength="60" placeholder="请输入设备名称" style="margin-left: 5px;width: 40vw;line-height: 25px;" />
					</div>
					<div class="flex-row mt-10">
						<div>设备型号</div>
						<input v-model="formData.deviceCode" :keyup="formData.deviceCode=formData.deviceCode.replace(/\s+/g,'')" maxlength="60" placeholder="请输入设备名称" style="margin-left: 5px;width: 40vw;line-height: 25px;" />
					</div>
					<div class="flex-row mt-10">
						<div>检查结果类型</div>
						<div class="flex-row" style="margin-left: 10px;">
							输入框 <input name="type" v-model="formData.resultType" value="1" style="width: 18px;margin-right: 5px;" type="radio" id="">
							单选框 <input name="type" v-model="formData.resultType" value="2" style="width: 18px;margin-right: 5px;" type="radio" id="">
						</div>
					</div>
					<div class="pop-bottom">
						<div @tap="addCheckItem">添加</div>
						<div class="color-red" @tap="showAdd=false">取消</div>
					</div>
				</div>
			</div>
			<div style="width: 100%;height: 60px;"></div>
			<div class="fixed-bottom flex-between">
				<button class="submit_btn" @click="save('0')">保存</button>
				<button class="submit_btn" @click="save('1')">提交</button>				
				<button @tap="back" class="cancel_btn">返回</button>
			</div>
		</div>
		</div>
		</div>


		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/vue.js"></script>
		<script type="text/javascript" src="../../../../js/jquery-3.2.1.min.js"></script>
		<script src="../../static/components/personSelect.js"></script>
		<script src="../../static/js/neiosCommon.js"></script>
		<script src="../../../../js/mui.picker.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../../js/mui.poppicker.js"></script>
		<script src="../../../../js/mui.picker.min.js"></script>
		<!--公共js页面必需-->
		<script type="text/javascript" src="../../static/js/neiosRequst.js"></script>
		<script src="../../static/components/processLog.js"></script>
		<!--流程日志-->
		<script type="text/javascript" charset="utf-8">
			document.addEventListener('focusout', function(e) {
				var classList = document.body.classList
				if (classList.contains('mui-focusin')) {
					classList.remove('mui-focusin')
				}
			})
			projectVM = new Vue({
				el: "#content",
				components: {
					personselect,
					processlog
				},
				data: {
					showAdd:false,
					list:[],
					nowDate:'',
					workId:'',
					checkId:'',
					workStatus:'',
					workDesc:'',
					RoomCheckVo:'',
					user:'',
					formData:{
						deviceName:'',
						deviceCode:'',
						resultType:1,
					}
				},
				created() {
					this.workId = JSON.parse(localStorage.getItem('todoWork')).obj.workId
					this.workStatus = JSON.parse(localStorage.getItem('todoWork')).obj.workStatus
					this.workDesc = JSON.parse(localStorage.getItem('todoWork')).obj.workDesc
					this.user = JSON.parse(localStorage.getItem('neiosUser'))
					mui.init()
					
				},
				mounted: function() {
					this.getDetail()
					this.getNowdate()
					
				},
				methods: {
					save(e){
						var that = this
						var able = true
						if(e == 1){
							var arr = this.list
							arr.forEach(item=>{
								if(item.deviceCode == ''){
									mui.toast('请输入设备型号')
									able = false
								}
								else if(item.deviceName == ''){
									mui.toast('请输入设备名称')
									able = false
								}
							
								else if(item.result == ''){
									mui.toast('请填写检查结果')
									able = false
								}
							})
						}
						if(!able){
							return
						}
						var param = {
							currentUser:this.user,
							neiosRoomCheckInfo:this.RoomCheckVo,
							roomInfoList:this.list,
							saveType:e,
							workId:this.workId,
							workType:"0403",
							workTypeName:"集控机房巡检"
						}
						console.log(JSON.stringify(param))
						
						mui.neiosRequst.httpRequst('/app/roomCheck/saveRoomCheck', param,
							(data)=> {
								console.log(JSON.stringify(data))
								mui.toast('操作成功')
								if (e == 0) {
									location.reload()
								} else {
									setTimeout(function() {
									that.goBack()
									}, 1000);
								}
							},
							function(data) {
						
							})
					},
					//返回
					back(){
						mui.back()	
					},
					//删除
					delItem(index){
						var that = this
						var btnArray = ['取消', '确认'];
						mui.confirm('是否确认删除?', '', btnArray, function(e) {
							if (e.index == 1) {
								
								that.list.splice(index,1)
							}	
						
						})
						
					},
				
					//添加	
					addCheckItem() {
						var _this = this
						if(this.formData.deviceCode == ''){
							mui.toast('请输入设备型号')
							return
						}
						else if(this.formData.deviceName == ''){
							mui.toast('请输入设备名称')
							return
						}
					let formData = this.formData
					formData.checkId = this.checkId
					formData.checkInfoId = ''
					formData.createBy=this.user.userId
					formData.createDate=this.nowDate
					formData.createStaffName=this.user.name
					formData.dataStatus = 1
					formData.modifyBy = this.user.userId
					formData.modifyDate = this.nowDate
					formData.modifyStaffName = this.user.name
					formData.remark = ''
					formData.result = ''
					let info = JSON.parse(JSON.stringify(formData))
					this.list.unshift(info)
					this.formData={
						deviceName:'',
						deviceCode:'',
						resultType:1,
					}
					this.showAdd = false
					},
					//返回上一页
					goBack() {
						setTimeout(function() {
							let page2 = plus.webview.getWebviewById("../sitOperation/terminalwork/terminalwork.html");
							let param = {}
							param.isRefresh = true
							mui.fire(page2, 'isRefresh', param);
							mui.back()
						}, 1000);
					},
					
					//删除
					deleteCheckItem(index) {
						if (this.checkItemNoteList[index].checkItemNoteId == null || this.checkItemNoteList[index].checkItemNoteId ==
							'') {
							this.checkItemNoteList.splice(index, 1);
						} else {
							this.delCheckItems.push(this.checkItemNoteList[index]);
							this.checkItemNoteList.splice(index, 1);
						}
					},
					//获取当前时间
					getNowdate() {
						var date = new Date()
						var year = date.getFullYear()
						var month = date.getMonth()
						var day = date.getDate()
						var hour = date.getHours()
						var min = date.getMinutes()
						 var sec = date.getSeconds()
						month = month*1 + 1
						if (month.toString().length < 2) {
							month = '0' + month
						}
						if (day.toString().length < 2) {
							day = '0' + day
						}
						if (hour.toString().length < 2) {
							hour = '0' + hour
						}
						if (min.toString().length < 2) {
							min = '0' + min
						}
						if (sec.toString().length < 2) {
							sec = '0' + sec
						}
						this.nowDate = year + '-' + month + '-' + day + ' ' + hour + ':' + min +':' + sec	
					},
					//流程退回
					sendBack() {
						if (this.advance == '') {
							mui.toast('请输入意见描述')
							return
						}
						var that = this
						var param = {
							"workId": this.workId,
							"workType": "0117",
							"nodeDealStaffCode": this.user.userId,
							"nodeDealStaffName": this.user.name,
							"approveDes": this.advance,
							"nodeDealStaffRole": '1',
							"forwardNode": '1',
							"nodeVisibleRange": '20',
							"workDesc":this.workDesc
						}
						mui.neiosRequst.httpRequst('/app/personWork/sendBack', param,
							(data)=> {
								mui.toast('操作成功')
								this.goBack()
							},
							function(data) {

							})
					},
					//获取列表
					getList(){
						var that = this
						var param = {
							checkId:this.checkId,
						}
						mui.neiosRequst.httpRequst('/app/roomCheck/getRoomCheckInfoByPage', param,
							(data)=> {
								console.log(JSON.stringify(data.data))
									if(data.code == 0){
											this.list = data.data
										
									}
									else{
										mui.toast(data.msg)
									}
							},
							function(data) {
						
							})
					},
					//获取工作详情
					getDetail() {
						var that = this
						var param = {
							workId:this.workId,
							newAreaCode:this.user.companyNewCode,
							currentUser:this.user
							
						}
						mui.neiosRequst.httpRequst('/app/roomCheck/getRoomCheckByworkId', param,
							(data)=> {
								console.log(JSON.stringify(data))
									if(data.data.RoomCheckVo != null){
										this.RoomCheckVo = data.data.RoomCheckVo
										this.checkId = data.data.RoomCheckVo.checkId
										this.getList()
									}
									else{
										this.RoomCheckVo = {
											checkCode:this.user.userId,											
											checkDate:this.nowDate,
											checkId:"",
											checkName:this.user.name,
											client:'',
											dataSource:'NEIOS_APP'+localStorage.getItem("currVersion"),
											dataStatus:'',
											modifyBy:this.user.userId,
											modifyDate:this.nowDate,
											modifyStaffName:this.user.name,
											newAreaCode:this.user.companyNewCode,
											remark:'',
											status:'',
											workId:this.workId,
										}
									}
						
							},
							function(data) {
						
							})
					}


				},

			})
		</script>
	</body>

</html>
